package com.school;

public class Test_3 {
    public static void main(String[] args) {
        Rodent []rodent = new Rodent[3];
        rodent[0]=new Mouse();
        rodent[1]=new Mole();
        rodent[2]=new Hamster();
        for(int i=0;i< rodent.length;i++){
            rodent[i].eat();
        }
    }
}

abstract class Rodent{
    public abstract void eat();
}

class Mouse extends Rodent{
    @Override
    public void eat() {
        System.out.println("老鼠杂食");
    }
}

class Mole extends Rodent{
    @Override
    public void eat() {
        System.out.println("鼹鼠吃昆虫");
    }
}
class Hamster extends Rodent{
    @Override
    public void eat() {
        System.out.println("仓鼠吃植物种子");
    }
}